﻿-- CHANGE IP ADDRESS
DECLARE @IP nchar(15)
SET @IP = '201.196.193.134'

-- CUSTOMER
-- SYSTEM MANAGER ROLE/PERMISSIONS
INSERT INTO [Customers] VALUES ('SmartParking', 'contactus@smartparkingonline.com', '6059-2156', 'San José', 0);
INSERT INTO [Roles] VALUES ('System Manager', 0);
INSERT INTO [Managers] VALUES (1, 1, 'sysman', 'spman2012CR', 'support@smartparkingonline.com', '6059-2156', 0);

INSERT INTO [Logs] VALUES (1, 'INSERT', 'Customers', '1', '', @IP, GETDATE())
INSERT INTO [Logs] VALUES (1, 'INSERT', 'Roles', '1', '', @IP, GETDATE())
INSERT INTO [Logs] VALUES (1, 'INSERT', 'Managers', '1', '', @IP, GETDATE())

INSERT INTO [Permissions] VALUES ('Login', 0);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'Permissions', '1', '', @IP, GETDATE())
INSERT INTO [RolePermissions] VALUES (1, 1);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'RolePermissions', '1-1', '', @IP, GETDATE())

INSERT INTO [Permissions] VALUES ('Roles Maintenance', 0);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'Permissions', '2', '', @IP, GETDATE())
INSERT INTO [RolePermissions] VALUES (1, 2);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'RolePermissions', '1-2', '', @IP, GETDATE())

INSERT INTO [Permissions] VALUES ('Permissions Maintenance', 0);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'Permissions', '3', '', @IP, GETDATE())
INSERT INTO [RolePermissions] VALUES (1, 3);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'RolePermissions', '1-3', '', @IP, GETDATE())

INSERT INTO [Permissions] VALUES ('Managers Maintenance', 0);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'Permissions', '4', '', @IP, GETDATE())
INSERT INTO [RolePermissions] VALUES (1, 4);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'RolePermissions', '1-4', '', @IP, GETDATE())

INSERT INTO [Permissions] VALUES ('Parkings Maintenance', 0);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'Permissions', '5', '', @IP, GETDATE())
INSERT INTO [RolePermissions] VALUES (1, 5);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'RolePermissions', '1-5', '', @IP, GETDATE())

INSERT INTO [Permissions] VALUES ('ParkingZones Maintenance', 0);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'Permissions', '6', '', @IP, GETDATE())
INSERT INTO [RolePermissions] VALUES (1, 6);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'RolePermissions', '1-6', '', @IP, GETDATE())

INSERT INTO [Permissions] VALUES ('ParkingZoneSpaces Maintenance', 0);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'Permissions', '7', '', @IP, GETDATE())
INSERT INTO [RolePermissions] VALUES (1, 7);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'RolePermissions', '1-7', '', @IP, GETDATE())

INSERT INTO [Permissions] VALUES ('Users Maintenance', 0);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'Permissions', '8', '', @IP, GETDATE())
INSERT INTO [RolePermissions] VALUES (1, 8);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'RolePermissions', '1-8', '', @IP, GETDATE())

INSERT INTO [Permissions] VALUES ('Reservations Maintenance', 0);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'Permissions', '9', '', @IP, GETDATE())
INSERT INTO [RolePermissions] VALUES (1, 9);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'RolePermissions', '1-9', '', @IP, GETDATE())

INSERT INTO [Permissions] VALUES ('Transactions Maintenance', 0);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'Permissions', '10', '', @IP, GETDATE())
INSERT INTO [RolePermissions] VALUES (1, 10);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'RolePermissions', '1-10', '', @IP, GETDATE())

-- WEB ROLE/PERMISSIONS
INSERT INTO [Roles] VALUES ('Web', 0);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'Roles', '2', '', @IP, GETDATE())

INSERT INTO [Permissions] VALUES ('Make Reservations', 0);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'Permissions', '11', '', @IP, GETDATE())
INSERT INTO [RolePermissions] VALUES (2, 11);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'RolePermissions', '1-11', '', @IP, GETDATE())


-- WEB MANAGER
INSERT INTO [Managers] VALUES (1, 2, 'webuser', 'spweb2012CR', 'support@smartparkingonline.com', '6059-2156', 0);
INSERT INTO [Logs] VALUES (1, 'INSERT', 'Managers', '2', '', @IP, GETDATE())




-- CREATE USER
--CREATE LOGIN nw WITH password='NWdba2013'
--CREATE USER nwUser FROM LOGIN nw;
--EXEC sp_addrolemember 'dbmanager', 'nwUser';